package cn.itlaobing.dao;

import cn.itlaobing.model.UserModel;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;

public class UserDao extends BaseDao<UserModel>{
	public UserModel queryAll(String username,String userpwd)throws ClassNotFoundException,SQLException
	{
		String sql="select * from users where userNumber=? and userPwd=?";
		UserModel um=null;
		ResultSet rs=db.queryExcute(sql,username,userpwd);
		if(rs.next())
		{
			um=new UserModel();
			um.setUserId(rs.getInt("userId"));
			um.setUserNumber(rs.getString("userNumber"));
			um.setUserPwd(rs.getString("userPwd"));
			um.setUserBeforeTime(rs.getDate("userBeforeTime"));
			um.setUserRealName(rs.getString("userRealName"));
			um.setUserPhone(rs.getString("userPhone"));
		}
		return um;
	}
	public int updateTime(Integer id)throws ClassNotFoundException,SQLException
	{
		String sql="update users set userBeforeTime=? where userId=?";
		int r=0;
		r=db.updateExcute(sql, new Date(),id);
		return r;
	}
}
